package com.lambda.use;

import org.junit.Test;

import java.util.function.Consumer;

/**
 * 功能描述
 *
 * @author: jichao.huang
 * @date: 2025年06月04日 17:08
 */
public class ConsumerUseTest {
    @Test
    public void testAccept() {
        Consumer<String> printer = System.out::println;

        printer.accept("Hello, World!");

        Consumer<String> consumer2 = (s) -> System.out.println(s);
        consumer2.accept("Hello, World!");
    }

    @Test
    public void testAndThen(){
        Consumer<String> consumer1 = (s) -> System.out.println("one:"+s);
        Consumer<String> consumer2 = (s) -> System.out.println("two:"+s);
        consumer1.andThen(consumer2).accept("Hello, World!");
    }
}
